package com.yootk.filter;

import jakarta.servlet.DispatcherType;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.annotation.WebInitParam;
import jakarta.servlet.http.HttpFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/*@WebFilter(
        urlPatterns = {"/pages/*", "/admin/*"}, // 过滤路径
        initParams = { // 初始化参数
                @WebInitParam(name = "message", value = "www.yootk.com")
        },
        dispatcherTypes = { // 转发模式
                //DispatcherType.REQUEST,
                DispatcherType.FORWARD
        })*/
public class BaseFilter extends HttpFilter {

    @Override
    protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("【BaseFilter.doFilter()】message = " + super.getInitParameter("message"));
        chain.doFilter(request, response); // 跳转到目标处理路径
    }
}
